#!/usr/bin/lua

require 'Test.More'
plan(14)

dofile '../plugins/cgcc/util.lua';

v = "1,2,3,4"
is(toCSV(fromCSV(v)), v)
v = "\"1,2\n\",3,4"
is(toCSV(fromCSV(v)), v)
a = toCSV({1,nil,2,3})
is(a, "1,2,3")
a = toCSV({1,"",2,3})
is(a, "1,,2,3")

a = roidsplit("Temperature: 12.3 K  Aquean Ore: 56.6%     Silicate Ore: 43.4%")
is(a.temp, "12.3");
is(a.Aquean, "56.6");
is(a.Silicate, "43.4");

s = {}
autovivify(s, "a", "b", "c")
ok(s.a)
ok(s.a.b)
ok(s.a.b.c)
s.a.b.c.d = "wow"
is(s.a.b.c.d,"wow")
autovivify(s, "a", "b", "c", "e")
is(s.a.b.c.d,"wow")
s.a.b.c.e = {["one"] = 1}
autovivify(s, "a", "b", "c", "e", "f")
ok(s.a.b.c.e.f)
is(s.a.b.c.e.one, 1)
